package com.example.back.Text;


import com.example.back.BackApplication;
import com.example.back.common.DeepSeekService;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.io.IOException;
import java.util.Scanner;

public class DeepSeekManualTest {
    public static Scanner scanner = new Scanner(System.in);
    public static void main(String[] args) throws IOException {
        // 1. 启动Spring容器（但只加载必要组件）
        ConfigurableApplicationContext context = SpringApplication.run(BackApplication.class, args);

        // 2. 获取Service实例
        DeepSeekService service = context.getBean(DeepSeekService.class);

        while (true) {
            // 3. 获取用户输入
            System.out.print("请输入问题（输入 exit 退出）：");
            String question = scanner.nextLine();

            if ("exit".equalsIgnoreCase(question)) {
                System.out.println("退出测试...");
                break;
            }

            // 4. 调用Service获取答案
            try {
                String response = service.getAiResponse(question);

                // 5. 输出答案
                System.out.println("答案：" + response);
            } catch (Exception e) {
                System.err.println("调用 AI 模型时发生错误: " + e.getMessage());
            }
        }
    }
}